<template>
  <div class="wrapper">
    <a-textarea v-model="value" placeholder="请输入作业名称" :rows="4" />
    <a-button type="primary" :style="{ margin: '50px 0' }" @click="publishHomework">发布作业</a-button>
  </div>
</template>

<script>
export default {
  name: 'publishHomework',
  data() {
    return {
      value: '',
    };
  },
  methods: {
    publishHomework() {
      const homeworkList = localStorage.getItem('homeworkList');
      if (homeworkList) {
        localStorage.setItem('homeworkList', JSON.stringify([...JSON.parse(homeworkList), this.value]));
      } else {
        localStorage.setItem('homeworkList', JSON.stringify([this.value]));
      }
      this.value = '';
    },
  },
};
</script>

<style lang="scss" scoped>
.wrapper {
  padding: 50px;
  width: calc(100vw - 256px);
}
</style>
